home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Tools&Utilities / TouchMe 1.2□ / touchMe 1.2 Folder / touchMe source codes / CW11 PP source / source / CTouchMeMainWindow.cp < prev    next >
Encoding:
Text File  |  1997-04-25  |  18.4 KB  |  674 lines  |  [TEXT/CWIE]

  1. // ==================================================
  2. //    CTouchMeMainWindow.cp
  3. //    Copyright (C) 1996-1997 Mizutori Tetsuya
  4. //    July 4, 1996; February 3, 1997; April 23, 1997.
  5. // ==================================================
  6. //    All documents are pretty-printed in 10-point Geneva font.
  7.  
  8. #include <LDialogBox.h>
  9. #include <LDragTask.h>
  10. #include <LStdControl.h>
  11. #include <LEditField.h>
  12. #include <LCaption.h>
  13. #include <LBroadcaster.h>
  14. #include <UDrawingState.h>
  15. #include <UDrawingUtils.h>
  16. #include <UMemoryMgr.h>
  17. #include <UDebugging.h>
  18. #include <LString.h>
  19.  
  20. #include <PP_Messages.h>
  21. #include <UReanimator.h>
  22.  
  23. #include "touchMeConstants.h"
  24. #include "CTouchMeMainWindow.h"
  25. #include "CRadioButton.h"
  26. #include "CDateEditField.h"
  27. #include "CTouchMePref.h"
  28. #include "UFileTools.h"
  29. #include "UDateTime.h"
  30. #include "UMacOSTools.h"
  31.  
  32.  
  33. #define    isButtonOn( xState )        ( (xState) == Button_On )
  34. #define    nButtonValue( xBoolean )    ( (xBoolean) ? Button_On : Button_Off  )
  35.  
  36.  
  37. // === Static Class Variables ===
  38. //Boolean    CTouchMeMainWindow::sGlobalModifier        = false;
  39.  
  40.  
  41. // --------------------------------------------------
  42. //        • CreateTouchMeMainWindowStream [static]
  43. // --------------------------------------------------
  44.  
  45. CTouchMeMainWindow *
  46. CTouchMeMainWindow::CreateTouchMeMainWindowStream(
  47.     LStream *        inStream )
  48. {
  49.     return new CTouchMeMainWindow( inStream );
  50. }
  51.  
  52.  
  53. // --------------------------------------------------
  54. //        • CTouchMeMainWindow(LStream *)
  55. // --------------------------------------------------
  56.  
  57. CTouchMeMainWindow::CTouchMeMainWindow(
  58.     LStream *        inStream )
  59.         : LDialogBox( inStream ),
  60.         LDragAndDrop( UQDGlobals::GetCurrentPort(), this )
  61. {
  62.     mGlobalModifier    = false;
  63.  
  64.     // For the drag & drop operations.
  65.     mModifier = false;
  66.     mTextDrag = false;
  67.     mHilitePaneID = kNoPaneID;
  68. }
  69.  
  70.  
  71. // --------------------------------------------------
  72. //        • ~CTouchMeMainWindow
  73. // --------------------------------------------------
  74.  
  75. CTouchMeMainWindow::~CTouchMeMainWindow()
  76. {
  77. }
  78.  
  79.  
  80. // ==================================================
  81. //    Member functions
  82. // ==================================================
  83.  
  84. // --------------------------------------------------
  85. //        • FinishCreateSelf
  86. // --------------------------------------------------
  87.  
  88. void
  89. CTouchMeMainWindow::FinishCreateSelf()
  90. {
  91.     LDialogBox::FinishCreateSelf();
  92.  
  93.     UReanimator::LinkListenerToControls( this, this, rRidL_TouchMeMainWindow );
  94.  
  95.     // This DialogBox listens to myself for the messages by a drag & drop operation.
  96.     this->AddListener( this );
  97.  
  98.     // Add listeners of CRadioButtons to broadcaster of LStdCheckBox.
  99.     // When the LStdCheckBox has changed, then change message will be sent to CRadioButtons.
  100.     LStdCheckBox *    theCheckBox;
  101.     CRadioButton *    theRadio;
  102.     PaneIDT        thePane;
  103.  
  104.     theCheckBox = (LStdCheckBox *) FindPaneByID( kMain_CrCheckbox );
  105.     for ( long i = 0; (thePane = kRadioGroupCreation[i]) != kNoPaneID; i++ ) {
  106.         theRadio = (CRadioButton *) FindPaneByID( thePane );
  107.         theCheckBox->AddListener( theRadio );
  108.     }
  109.  
  110.     theCheckBox = (LStdCheckBox *) FindPaneByID( kMain_MdCheckbox );
  111.     for ( long i = 0; (thePane = kRadioGroupModification[i]) != kNoPaneID; i++ ) {
  112.         theRadio = (CRadioButton *) FindPaneByID( thePane );
  113.         theCheckBox->AddListener( theRadio );
  114.     }
  115.  
  116. }
  117.  
  118.  
  119. // --------------------------------------------------
  120. //        • DrawSelf
  121. // --------------------------------------------------
  122. // Draw my additional custom figures in the dialog window.
  123. // This procedure erases the 2-pixel width region near the bound.
  124. // The reason is that the 2-pixel region may not be hilited properly
  125. // during a drag & drop because my window is colored at background.
  126. // ->See HiliteDropArea(). We call ApplyForeAndBackColors() in it, instead.
  127.  
  128. void
  129. CTouchMeMainWindow::DrawSelf( void )
  130. {
  131. //    StColorPenState    theCurrentState;
  132. //    LDialogBox::DrawSelf();
  133. //    StColorPenState::Normalize();
  134.  
  135.     // Set the foreground and background colors of the current port.
  136.     ApplyForeAndBackColors();
  137.  
  138.     // Draw a very tiny spot at the top-left corner of the window.
  139.     Rect        theRect;
  140.     ::SetRect( &theRect, 3, 3, 8, 8 );    // (left,top,right,bottom)
  141.  
  142.     if ( mGlobalModifier ) ::FillRect( &theRect, &(qd.gray) );
  143.     else ::EraseRect( &theRect );
  144.  
  145. #ifdef COMMENT
  146.     RgnHandle    theRgnH = ::NewRgn();
  147.     RgnHandle    theInRgnH = ::NewRgn();
  148.  
  149.     Rect        theRect;
  150.     CalcLocalFrameRect( theRect );
  151.     ::RectRgn( theRgnH, &theRect );
  152.     ::InsetRect( &theRect, 2, 2);
  153.     ::RectRgn( theInRgnH, &theRect );
  154.     ::DiffRgn( theRgnH, theInRgnH, theRgnH );
  155.  
  156.     ::EraseRgn( theRgnH );
  157.  
  158.     ::DisposeRgn( theRgnH );
  159.     ::DisposeRgn( theInRgnH );
  160. #endif // COMMENT
  161. }
  162.  
  163.  
  164. // --------------------------------------------------
  165. //        • FindCommandStatus
  166. // --------------------------------------------------
  167.  
  168. void
  169. CTouchMeMainWindow::FindCommandStatus(
  170.     CommandT        inCommand,
  171.     Boolean &        outEnabled,
  172.     Boolean &        outUsesMark,
  173.     Char16 &        outMark,
  174.     Str255        outName )
  175. {
  176. #pragma unused ( outUsesMark, outMark, outName )
  177.  
  178.     switch (inCommand) {
  179.         case cmd_About:
  180.         case cmd_Open:
  181.         case cmd_Close:
  182.         case cmd_Save:
  183.         case cmd_Quit:
  184.             outEnabled = true;
  185.             break;
  186.         case cmd_New:
  187.         default:
  188.             outEnabled = false;
  189.             break;
  190.     }
  191. }
  192.  
  193.  
  194.  
  195. // --------------------------------------------------
  196. //        • ListenToMessage
  197. // --------------------------------------------------
  198.  
  199. void
  200. CTouchMeMainWindow::ListenToMessage(
  201.     MessageT        inMessage,
  202.     void *        ioParam )
  203. {
  204.     switch ( inMessage ) {
  205.  
  206.         case msg_Main_ButtonOK:
  207.         {
  208.             // Store the preference data to Prefs file.
  209.             ProcessCommand( msg_SavePrefs, ioParam );
  210.             ProcessCommand( msg_Main_ButtonOK, ioParam );
  211.         //    LDialogBox::ListenToMessage( inMessage, ioParam );
  212.         }
  213.         break;
  214.  
  215.         case msg_Main_ButtonCencel:
  216.         {
  217.             // Discard the preference data.
  218.             ProcessCommand( msg_SavePrefsWFrame, ioParam );
  219.             ProcessCommand( msg_Main_ButtonCencel, ioParam );
  220.         //    LDialogBox::ListenToMessage( inMessage, ioParam );
  221.         }
  222.         break;
  223.  
  224.         case cmd_Save:
  225.         {
  226.             // Save the preferences data.
  227.             ProcessCommand( msg_SavePrefs, ioParam );
  228.         }
  229.         break;
  230.  
  231.         case msg_Main_ButtonHelp:
  232.         {
  233.             // Show the help window.
  234.             ProcessCommand( msg_Help, ioParam );
  235.         }
  236.         break;
  237.  
  238.         case msg_Main_Title:
  239.         {
  240.             // Show the About window.
  241.             // But this does not work because 'Title' pane is not enabled now.
  242.             ProcessCommand( cmd_About, ioParam );
  243.         }
  244.         break;
  245.  
  246.         case msg_Main_CrButtonNow:
  247.         {
  248.             // Set up creation date time EditFields to the current date time.
  249.             unsigned long    theDateTimeSecs;
  250.             ::GetDateTime( &theDateTimeSecs );
  251.  
  252.             if ( mGlobalModifier ) {
  253.                 Str63    dateStr, timeStr;
  254.                 UDateTime::SecondsToDateTimeString(theDateTimeSecs,dateStr,timeStr);
  255.                 LString::CopyPStr( "\p0:0:0", timeStr );
  256.                 UDateTime::DateTimeStringToSeconds(dateStr,timeStr,theDateTimeSecs);
  257.             }
  258.  
  259.             SetEditFieldDateTime( kMain_CrTextEditDate, theDateTimeSecs );
  260.             SetEditFieldDateTime( kMain_CrTextEditTime, theDateTimeSecs );
  261.  
  262.             if ( GetValueForPaneID( kMain_ButtonSync ) == Button_On ) {
  263.             SetEditFieldDateTime( kMain_MdTextEditDate, theDateTimeSecs );
  264.             SetEditFieldDateTime( kMain_MdTextEditTime, theDateTimeSecs );
  265.             }
  266.         }
  267.         break;
  268.  
  269.         case msg_Main_MdButtonNow:
  270.         {
  271.             // Set up modification date time EditFields to the current date time.
  272.             unsigned long    theDateTimeSecs;
  273.             ::GetDateTime( &theDateTimeSecs );
  274.  
  275.             if ( mGlobalModifier ) {
  276.                 Str63    dateStr, timeStr;
  277.                 UDateTime::SecondsToDateTimeString(theDateTimeSecs,dateStr,timeStr);
  278.                 LString::CopyPStr( "\p0:0:0", timeStr );
  279.                 UDateTime::DateTimeStringToSeconds(dateStr,timeStr,theDateTimeSecs);
  280.             }
  281.  
  282.             SetEditFieldDateTime( kMain_MdTextEditDate, theDateTimeSecs );
  283.             SetEditFieldDateTime( kMain_MdTextEditTime, theDateTimeSecs );
  284.  
  285.             if ( GetValueForPaneID( kMain_ButtonSync ) == Button_On ) {
  286.             SetEditFieldDateTime( kMain_CrTextEditDate, theDateTimeSecs );
  287.             SetEditFieldDateTime( kMain_CrTextEditTime, theDateTimeSecs );
  288.             }
  289.         }
  290.         break;
  291.  
  292.         case msg_Main_DroppedFile:
  293.         {
  294.             // Setup date time EditFields according to the date time stamp of the dropped file.
  295.             // Parameter: FSSpec *ioParam
  296.             FSSpec        * theFSSpec = (FSSpec *) ioParam;
  297.             unsigned long    theCrDateTime = 0, theMdDateTime = 0;
  298.             UFileTools::GetFSSpecDateTime( *theFSSpec, theCrDateTime, theMdDateTime );
  299.  
  300.             SetEditFieldDateTime( kMain_CrTextEditDate, theCrDateTime );
  301.             SetEditFieldDateTime( kMain_CrTextEditTime, theCrDateTime );
  302.  
  303.             SetEditFieldDateTime( kMain_MdTextEditDate, theMdDateTime );
  304.             SetEditFieldDateTime( kMain_MdTextEditTime, theMdDateTime );
  305.         }
  306.         break;
  307.  
  308.         case msg_Main_DroppedFileCrDate:
  309.         case msg_Main_DroppedFileCrTime:
  310.         case msg_Main_DroppedFileMdDate:
  311.         case msg_Main_DroppedFileMdTime:
  312.         {
  313.             // Setup date time EditFields separately according to the dropped file.
  314.             FSSpec        * theFSSpec = (FSSpec *) ioParam;
  315.             unsigned long    theCrDateTime = 0, theMdDateTime = 0;
  316.             UFileTools::GetFSSpecDateTime( *theFSSpec, theCrDateTime, theMdDateTime );
  317.  
  318.             switch ( inMessage ) {
  319.                 case msg_Main_DroppedFileCrDate:
  320.                     SetEditFieldDateTime( kMain_CrTextEditDate, theCrDateTime ); break;
  321.                 case msg_Main_DroppedFileCrTime:
  322.                     SetEditFieldDateTime( kMain_CrTextEditTime, theCrDateTime ); break;
  323.                 case msg_Main_DroppedFileMdDate:
  324.                     SetEditFieldDateTime( kMain_MdTextEditDate, theMdDateTime ); break;
  325.                 case msg_Main_DroppedFileMdTime:
  326.                     SetEditFieldDateTime( kMain_MdTextEditTime, theMdDateTime ); break;
  327.             }
  328.         }
  329.         break;
  330.  
  331.         case msg_Main_DroppedTextCrDate:
  332.         case msg_Main_DroppedTextCrTime:
  333.         case msg_Main_DroppedTextMdDate:
  334.         case msg_Main_DroppedTextMdTime:
  335.         {
  336.             // Setup date time EditFields separately according to the dropped 'TEXT'.
  337.             StringPtr        str = (StringPtr) ioParam;
  338.  
  339.             switch ( inMessage ) {
  340.                 case msg_Main_DroppedTextCrDate:
  341.                     SetEditFieldText( kMain_CrTextEditDate, str); break;
  342.                 case msg_Main_DroppedTextCrTime:
  343.                     SetEditFieldText( kMain_CrTextEditTime, str); break;
  344.                 case msg_Main_DroppedTextMdDate:
  345.                     SetEditFieldText( kMain_MdTextEditDate, str); break;
  346.                 case msg_Main_DroppedTextMdTime:
  347.                     SetEditFieldText( kMain_MdTextEditTime, str); break;
  348.             }
  349.         }
  350.         break;
  351.  
  352.         case msg_Main_CrCheckbox:
  353.         case msg_Main_MdCheckbox:
  354.         {
  355.             // Do nothing here.
  356.         }
  357.         break;
  358.  
  359.         case msg_Main_CrButtonCurrent:
  360.         case msg_Main_CrButtonDirect:
  361.         case msg_Main_CrButtonFirst:
  362.         case msg_Main_CrButtonSecond:
  363.         case msg_Main_MdButtonCurrent:
  364.         case msg_Main_MdButtonDirect:
  365.         case msg_Main_MdButtonFirst:
  366.         case msg_Main_MdButtonSecond:
  367.         {
  368.             // Notice that the value of the message is same to the pane ID of the radio button.
  369.             PaneIDT    thePane = (PaneIDT) inMessage;
  370.             PaneIDT    theOtherPane = GetPairedPaneID( thePane );
  371.             if ( GetValueForPaneID( kMain_ButtonSync ) == Button_On )
  372.             if ( GetValueForPaneID( thePane ) == Button_On )
  373.                 SetValueForPaneID( theOtherPane, Button_On );
  374.         }
  375.         break;
  376.  
  377.         default:
  378.         {
  379.             LDialogBox::ListenToMessage( inMessage, ioParam );
  380.             break;
  381.         }
  382.  
  383.     }
  384. }
  385.  
  386.  
  387. // --------------------------------------------------
  388. //        • AttemptClose
  389. // --------------------------------------------------
  390. // Quit program like as "Cancel" button if "Close Box" was selected.
  391.  
  392. void
  393. CTouchMeMainWindow::AttemptClose( void )
  394. {
  395.     //LDialogBox::AttemptClose();
  396.  
  397.     BroadcastMessage( msg_Main_ButtonCencel, (void *) nil );
  398. }
  399.  
  400.  
  401. // ==================================================
  402. //    Member functions (read or write dialog settings)
  403. // ==================================================
  404.  
  405. // --------------------------------------------------
  406. //        • SetupDialog
  407. // --------------------------------------------------
  408. // Setup dialog status according to the member variables mPrefs.
  409.  
  410. void
  411. CTouchMeMainWindow::SetupDialog(
  412.     const SPrefsRec &    inPrefs )
  413. {
  414.     // Set the window position.
  415.     Rect        theWindowRect = inPrefs.wframe;
  416.     if ( ! ::EmptyRect( &theWindowRect ) ) {
  417.         DoSetPosition( topLeft( theWindowRect ));
  418.     }
  419.  
  420.     SetValueForPaneID( kMain_CrCheckbox,
  421.             nButtonValue( inPrefs.enabled[ touchType_CreationDate - touchType_CreationDate ] ) );
  422.  
  423.     SetValueForPaneID( kMain_MdCheckbox,
  424.             nButtonValue( inPrefs.enabled[ touchType_ModificationDate - touchType_CreationDate ] ) );
  425.  
  426.     SetValueForPaneID( kMain_ButtonSync, nButtonValue( inPrefs.sync ) );
  427.  
  428.  
  429.     // Because we're about to set the value for controls
  430.     // we're listening to we'll turn off listening temporarily.
  431.     // Otherwise we'll get in a tug-of-war
  432.     // as the controls broadcast their changing values.
  433.     StopListening();
  434.  
  435.     PaneIDT    thePane;
  436.     for ( long i = touchFlag_Current; (thePane = kRadioGroupCreation[i-touchFlag_Current]) != kNoPaneID; i++ ) {
  437.         SetValueForPaneID( thePane,  nButtonValue(false) );
  438.         if ( i == inPrefs.flag[touchType_CreationDate - touchType_CreationDate] )
  439.             SetValueForPaneID( thePane,  nButtonValue(true) );
  440.     }
  441.  
  442.     for ( long i = touchFlag_Current; (thePane = kRadioGroupModification[i-touchFlag_Current]) != kNoPaneID; i++ ) {
  443.         SetValueForPaneID( thePane, nButtonValue(false) );
  444.         if ( i == inPrefs.flag[touchType_ModificationDate - touchType_CreationDate] )
  445.             SetValueForPaneID( thePane, nButtonValue(true) );
  446.     }
  447.  
  448.     // Start listening again.
  449.     StartListening();
  450.  
  451.  
  452.     Str255    strDate, strTime;
  453.  
  454.     UDateTime::SecondsToDateTimeString(
  455.                 inPrefs.datetime[ touchType_CreationDate - touchType_CreationDate ], strDate, strTime );
  456.     SetEditFieldText( kMain_CrTextEditDate, strDate);
  457.     SetEditFieldText( kMain_CrTextEditTime, strTime);
  458.  
  459.     UDateTime::SecondsToDateTimeString(
  460.                 inPrefs.datetime[ touchType_ModificationDate - touchType_CreationDate ], strDate, strTime );
  461.     SetEditFieldText( kMain_MdTextEditDate, strDate);
  462.     SetEditFieldText( kMain_MdTextEditTime, strTime);
  463. }
  464.  
  465.  
  466. // --------------------------------------------------
  467. //        • InspectDialog
  468. // --------------------------------------------------
  469.  
  470. void
  471. CTouchMeMainWindow::InspectDialog(
  472.     SPrefsRec &        outPrefs )
  473. {
  474.     // Get the window position.
  475.     Rect        theWindowRect;
  476.     GetGlobalFrameRect( theWindowRect );
  477.     outPrefs.wframe = theWindowRect;
  478.  
  479.     outPrefs.enabled[ touchType_CreationDate - touchType_CreationDate] =
  480.                 isButtonOn( GetValueForPaneID( kMain_CrCheckbox ) );
  481.  
  482.     outPrefs.enabled[ touchType_ModificationDate - touchType_CreationDate] =
  483.                 isButtonOn( GetValueForPaneID( kMain_MdCheckbox ) );
  484.  
  485.     outPrefs.sync = isButtonOn( GetValueForPaneID( kMain_ButtonSync ) );
  486.  
  487.  
  488.     PaneIDT    thePane;
  489.     outPrefs.flag[touchType_CreationDate - touchType_CreationDate] = touchFlag_Current;
  490.     for ( long i = touchFlag_Current; (thePane = kRadioGroupCreation[i-touchFlag_Current]) != kNoPaneID; i++ ) {
  491.         if ( isButtonOn( GetValueForPaneID(thePane) ) ) {
  492.             outPrefs.flag[touchType_CreationDate - touchType_CreationDate] = i;
  493.             break;
  494.         }
  495.     }
  496.  
  497.     outPrefs.flag[touchType_ModificationDate - touchType_CreationDate] = touchFlag_Current;
  498.     for ( long i = touchFlag_Current; (thePane = kRadioGroupModification[i-touchFlag_Current]) != kNoPaneID; i++ ) {
  499.         if ( isButtonOn( GetValueForPaneID(thePane) ) ) {
  500.             outPrefs.flag[touchType_ModificationDate - touchType_CreationDate] = i;
  501.             break;
  502.         }
  503.     }
  504.  
  505.     Str255    strDate, strTime;
  506.  
  507.     GetEditFieldText( kMain_CrTextEditDate, strDate );
  508.     GetEditFieldText( kMain_CrTextEditTime, strTime);
  509.     UDateTime::DateTimeStringToSeconds( strDate, strTime,
  510.                 outPrefs.datetime[ touchType_CreationDate - touchType_CreationDate ] );
  511.  
  512.     GetEditFieldText( kMain_MdTextEditDate, strDate);
  513.     GetEditFieldText( kMain_MdTextEditTime, strTime);
  514.     UDateTime::DateTimeStringToSeconds( strDate, strTime,
  515.                 outPrefs.datetime[ touchType_ModificationDate - touchType_CreationDate ] );
  516. }
  517.  
  518.  
  519.  
  520. // ==================================================
  521. //    Member functions
  522. // ==================================================
  523.  
  524. // --------------------------------------------------
  525. //        • GetGlobalFrameRect
  526. // --------------------------------------------------
  527. // Get the global frame rect, a bound of dialog
  528.  
  529. void
  530. CTouchMeMainWindow::GetGlobalFrameRect(
  531.     Rect &    outRect )
  532. {
  533.     CalcPortFrameRect( outRect );
  534.     PortToGlobalPoint( topLeft( outRect ) );
  535.     PortToGlobalPoint( botRight( outRect ) );
  536. }
  537.  
  538.  
  539. // --------------------------------------------------
  540. //        • MoveWindow
  541. // --------------------------------------------------
  542. // Move the dialog window
  543.  
  544. void
  545. CTouchMeMainWindow::MoveWindow(
  546.     Rect &    inRect  )
  547. {
  548.     if ( ! ::EmptyRect( &inRect ) ) {
  549.         DoSetPosition( topLeft( inRect ));
  550.     }
  551. }
  552.  
  553.  
  554.  
  555. // ==================================================
  556. //    Common functions
  557. // ==================================================
  558.  
  559. // --------------------------------------------------
  560. //        • SetEditFieldText
  561. // --------------------------------------------------
  562.  
  563. void
  564. CTouchMeMainWindow::SetEditFieldText(
  565.     PaneIDT        inPane,
  566.     const Str255    inString,
  567.     Boolean        toSelectAll )    //= false
  568. {
  569.     CDateEditField *    theEditField;
  570.  
  571.     theEditField = (CDateEditField *) FindPaneByID( inPane );
  572.     theEditField->SetText( inString );
  573.  
  574.     if ( toSelectAll ) theEditField->SelectAll();
  575. }
  576.  
  577.  
  578. // --------------------------------------------------
  579. //        • SetEditFieldTextRefresh
  580. // --------------------------------------------------
  581.  
  582. void
  583. CTouchMeMainWindow::SetEditFieldTextRefresh(
  584.     PaneIDT        inPane,
  585.     const Str255    inString,
  586.     Boolean        toSelectAll )    //= false
  587. {
  588.     CDateEditField *    theEditField;
  589.  
  590.     theEditField = (CDateEditField *) FindPaneByID( inPane );
  591.     theEditField->SetTextAndRefresh( inString );
  592.  
  593.     if ( toSelectAll ) theEditField->SelectAll();
  594. }
  595.  
  596.  
  597. // --------------------------------------------------
  598. //        • GetEditFieldText
  599. // --------------------------------------------------
  600.  
  601. void
  602. CTouchMeMainWindow::GetEditFieldText(
  603.     PaneIDT        inPane,
  604.     Str255        outString,
  605.     Boolean        toSelectAll )    //= false
  606. {
  607.     CDateEditField *    theEditField;
  608.  
  609.     theEditField = (CDateEditField *) FindPaneByID( inPane );
  610.     theEditField->GetText( outString );
  611.  
  612.     if ( toSelectAll ) theEditField->SelectAll();
  613. }
  614.  
  615.  
  616. // --------------------------------------------------
  617. //        • SetEditFieldDateTime
  618. // --------------------------------------------------
  619.  
  620. void
  621. CTouchMeMainWindow::SetEditFieldDateTime(
  622.     PaneIDT            inPane,
  623.     const unsigned long    inDateTimeSeconds,
  624.     Boolean            toSelectAll )    //= false
  625. {
  626.     CDateEditField *    theEditField;
  627.  
  628.     theEditField = (CDateEditField *) FindPaneByID( inPane );
  629.     theEditField->SetDateTime( inDateTimeSeconds );
  630.  
  631.     if ( toSelectAll ) theEditField->SelectAll();
  632. }
  633.  
  634.  
  635. // --------------------------------------------------
  636. //        • GetPairedPaneID
  637. // --------------------------------------------------
  638.  
  639. PaneIDT
  640. CTouchMeMainWindow::GetPairedPaneID(
  641.     const PaneIDT        inPaneID )
  642. {
  643.     PaneIDT    thePane;
  644.  
  645.     for ( long i=0; (thePane = kRadioGroupCreation[i]) != kNoPaneID; i++ ) {
  646.         if ( thePane == inPaneID ) return kRadioGroupModification[i];
  647.     }
  648.  
  649.     for ( long i=0; (thePane = kRadioGroupModification[i]) != kNoPaneID; i++ ) {
  650.         if ( thePane == inPaneID ) return kRadioGroupCreation[i];
  651.     }
  652.  
  653.     return kNoPaneID;
  654. }
  655.  
  656.  
  657. // --------------------------------------------------
  658. //        • Indicator
  659. // --------------------------------------------------
  660. // I prefer to show a very tiny spot at the corner to indicate the status.
  661.  
  662. void
  663. CTouchMeMainWindow::Indicator(
  664.     const Boolean    inStatus )
  665. {
  666.     if ( inStatus != mGlobalModifier ) {
  667.         mGlobalModifier = inStatus;
  668.         if ( FocusDraw() ) DrawSelf();
  669.     }
  670. }
  671.  
  672.  
  673. // end of program
  674.